package com.imchenio.springscheduleexample.instance04;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

@Slf4j
public class ScheduleThreadPoolExecutorRunner {

//    public static void main(String[] args) {
//        ScheduledExecutorService pool = new ScheduledThreadPoolExecutor(5);
//
//        pool.schedule(() -> log.info("run 5 seconds after"), 5, TimeUnit.SECONDS);
//        //pool.scheduleAtFixedRate(ScheduleThreadPoolExecutorRunner::run, 0, 5, TimeUnit.SECONDS);
//        //pool.scheduleWithFixedDelay(ScheduleThreadPoolExecutorRunner::run, 0 , 5, TimeUnit.SECONDS);
//    }

    public static void run() {
        log.info("run in 5 seconds");
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
